/*
ONEGAME
Copyright (C) 2009  Pablo Caballero

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package swing;

import java.awt.Dialog;
import java.awt.Dialog.ModalityType;
import java.awt.Frame;
import java.awt.GraphicsConfiguration;
import java.awt.Point;
import java.awt.Toolkit;
import java.awt.Window;
import javax.swing.JDialog;

/**
 * A dialog centered in the middle of the screen
 * @author Pablo Caballero
 * @version 1.0 23-jun-2009
 */
public class JCenteredDialog extends JDialog {

	public JCenteredDialog(Window owner, String title, ModalityType modalityType, GraphicsConfiguration gc) {
		super(owner, title, modalityType, gc);
	}

	public JCenteredDialog(Window owner, String title, ModalityType modalityType) {
		super(owner, title, modalityType);
	}

	public JCenteredDialog(Window owner, String title) {
		super(owner, title);
	}

	public JCenteredDialog(Window owner, ModalityType modalityType) {
		super(owner, modalityType);
	}

	public JCenteredDialog(Window owner) {
		super(owner);
	}

	public JCenteredDialog(Dialog owner, String title, boolean modal, GraphicsConfiguration gc) {
		super(owner, title, modal, gc);
	}

	public JCenteredDialog(Dialog owner, String title, boolean modal) {
		super(owner, title, modal);
	}

	public JCenteredDialog(Dialog owner, String title) {
		super(owner, title);
	}

	public JCenteredDialog(Dialog owner) {
		super(owner);
	}

	public JCenteredDialog(Frame owner, String title, boolean modal, GraphicsConfiguration gc) {
		super(owner, title, modal, gc);
	}

	public JCenteredDialog(Frame owner, String title, boolean modal) {
		super(owner, title, modal);
	}

	public JCenteredDialog(Frame owner, String title) {
		super(owner, title);
	}

	public JCenteredDialog(Frame owner, boolean modal) {
		super(owner, modal);
	}

	public JCenteredDialog(Frame owner) {
		super(owner);
	}

	public JCenteredDialog() {
		super();
	}

	@Override
	public void setVisible(boolean b) {
		Point p;
		Toolkit toolkit;

		if (b) {
			toolkit = getToolkit();
			p = new Point((toolkit.getScreenSize().width - this.getWidth()) / 2, (toolkit.getScreenSize().height - this.getHeight()) / 2);
			setLocation(p);
		}

		super.setVisible(b);
	}
}
